/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Reportes;
import java.util.Vector;
import Model.Cliente;
import java.io.File;
import java.sql.ResultSet;
import java.util.Locale;
import jxl.CellReferenceHelper;
import jxl.CellView;
import jxl.HeaderFooter;
import jxl.Range;
import jxl.Workbook;
import jxl.WorkbookSettings;
import jxl.format.Alignment;
import jxl.format.Border;
import jxl.format.BorderLineStyle;
import jxl.format.Colour;
import jxl.format.Orientation;
import jxl.format.PageOrder;
import jxl.format.PageOrientation;
import jxl.format.PaperSize;
import jxl.format.ScriptStyle;
import jxl.format.UnderlineStyle;
import jxl.write.Blank;
import jxl.write.Boolean;
import jxl.write.DateFormat;
import jxl.write.DateFormats;
import jxl.write.DateTime;
import jxl.write.Formula;
import jxl.write.Label;
import jxl.write.Number;
import jxl.write.NumberFormat;
import jxl.write.NumberFormats;
import jxl.write.WritableCellFeatures;
import jxl.write.WritableCellFormat;
import jxl.write.WritableFont;
import jxl.write.WritableHyperlink;
import jxl.write.WritableImage;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import jxl.write.WriteException;
/**
 *
 * @author usuario
 */
public class rGastoTipoCong extends ManejaExcel {

    public rGastoTipoCong(String name, String param1, String param2,int opc1, String opc2){
        super(name,param1,param2,opc1,opc2);
        
    }

    
    protected void escribirInfo() {

       try{ 

        WritableSheet s1 = workbook.createSheet("Clientes", 0);
        s1.setColumnView(1,25);
        s1.setColumnView(2,25);
        s1.setColumnView(3,30);
        
       
        //Carga primer fila con los titulos
        Label l1 = new Label(1,0,"Congreso", arial10BoldFormat);
        s1.addCell(l1);
        Label l3 = new Label(2,0,"Tipo", arial10BoldFormat);
        s1.addCell(l3);
         Label l5 = new Label(3,0,"Monto", arial10BoldFormat);
        s1.addCell(l5);

        Number n7;
        //Trae la info indicada
         String consulta="SELECT SUM(Monto) as Montotal, Tg.Tipo as type,Iniciales_Congreso " +
                 " FROM Gastos G join Tipo_Gasto TG on G.Tipo=TG.Id_Tipo "+
                 where() +" GROUP BY TG.Tipo,Iniciales_Congreso,Fecha_Congreso ";
        ResultSet resultSet = traeInfo(consulta);
           //Carga todas las filas 
        int i=0;
        while (resultSet.next()){
            i=i+1;
            l1 = new Label(1,i,resultSet.getString("Iniciales_Congreso"), wrappedText);
            s1.addCell(l1);
            l3 = new Label(2,i,resultSet.getString("type"), wrappedText);
            s1.addCell(l3);
            n7 = new Number(3,i,resultSet.getDouble("Montotal"), wrappedText);
            s1.addCell(n7);

        }
            l3 = new Label(2,i+1,"TOTAL:", arial10BoldFormat);
            s1.addCell(l3);
            Formula f7 = new Formula(3,i+1,"SUM(d2:d"+(i+1)+")",wrappedText);
            if (i>0) s1.addCell(f7);
         }catch(Exception e){e.printStackTrace();}
    }
    
}
